#define SQLITE_MAX_EXPR_DEPTH

using Community.CsharpSqlite.Entity;
using unsigned = System.UInt64;
#if !SQLITE_MAX_VARIABLE_NUMBER
using ynVar = System.Int16;

#else
using ynVar = System.Int32; 
#endif

namespace Community.CsharpSqlite
{
    using sqlite3_value = Mem;

    public partial class Sqlite3
    {
        /*
    ** 2001 September 15
    **
    ** The author disclaims copyright to this source code.  In place of
    ** a legal notice, here is a blessing:
    **
    **    May you do good and not evil.
    **    May you find forgiveness for yourself and forgive others.
    **    May you share freely, never taking more than you give.
    **
    *************************************************************************
    ** Internal interface definitions for SQLite.
    **
    *************************************************************************
    **  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
    **  C#-SQLite is an independent reimplementation of the SQLite software library
    **
    **  SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
    **
    **  $Header: Community.CsharpSqlite/src/sqliteInt_h.cs,v 6604176a7dbe 2010/03/12 23:35:36 Noah $
    *************************************************************************
    */
        //#if !_SQLITEINT_H_
        //#define _SQLITEINT_H_

        /*
    ** These #defines should enable >2GB file support on POSIX if the
    ** underlying operating system supports it.  If the OS lacks
    ** large file support, or if the OS is windows, these should be no-ops.
    **
    ** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any
    ** system #includes.  Hence, this block of code must be the very first
    ** code in all source files.
    **
    ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
    ** on the compiler command line.  This is necessary if you are compiling
    ** on a recent machine (ex: Red Hat 7.2) but you want your code to work
    ** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2
    ** without this option, LFS is enable.  But LFS does not exist in the kernel
    ** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary
    ** portability you should omit LFS.
    **
    ** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.
    */
        //#if !SQLITE_DISABLE_LFS
        //# define _LARGE_FILE       1
        //# ifndef _FILE_OFFSET_BITS
        //#   define _FILE_OFFSET_BITS 64
        //# endif
        //# define _LARGEFILE_SOURCE 1
        //#endif

        /*
    ** Include the configuration header output by 'configure' if we're using the
    ** autoconf-based build
    */
#if _HAVE_SQLITE_CONFIG_H
//#include "config.h"
#endif
        //#include "sqliteLimit.h"

        /* Disable nuisance warnings on Borland compilers */
        //#if defined(__BORLANDC__)
        //#pragma warn -rch /* unreachable code */
        //#pragma warn -ccc /* Condition is always true or false */
        //#pragma warn -aus /* Assigned value is never used */
        //#pragma warn -csu /* Comparing signed and unsigned */
        //#pragma warn -spa /* Suspicious pointer arithmetic */
        //#endif

        /* Needed for various definitions... */
        //#if !_GNU_SOURCE
        //#define _GNU_SOURCE
        //#endif
        /*
    ** Include standard header files as necessary
    */
#if HAVE_STDINT_H
//#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
//#include <inttypes.h>
#endif

        /*
** The number of samples of an index that SQLite takes in order to 
** construct a histogram of the table content when running ANALYZE
** and with SQLITE_ENABLE_STAT2
*/
        //#define SQLITE_INDEX_SAMPLES 10
        public const int SQLITE_INDEX_SAMPLES = 10;

        /*
    ** The following macros are used to cast pointers to integers and
    ** integers to pointers.  The way you do this varies from one compiler
    ** to the next, so we have developed the following set of #if statements
    ** to generate appropriate macros for a wide range of compilers.
    **
    ** The correct "ANSI" way to do this is to use the intptr_t type. 
    ** Unfortunately, that typedef is not available on all compilers, or
    ** if it is available, it requires an #include of specific headers
    ** that very from one machine to the next.
    **
    ** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on
    ** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).
    ** So we have to define the macros in different ways depending on the
    ** compiler.
    */
        //#if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */
        //# define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))
        //# define SQLITE_PTR_TO_INT(X)  ((int)(__PTRDIFF_TYPE__)(X))
        //#elif !defined(__GNUC__)       /* Works for compilers other than LLVM */
        //# define SQLITE_INT_TO_PTR(X)  ((void*)&((char*)0)[X])
        //# define SQLITE_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))
        //#elif defined(HAVE_STDINT_H)   /* Use this case if we have ANSI headers */
        //# define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))
        //# define SQLITE_PTR_TO_INT(X)  ((int)(intptr_t)(X))
        //#else                          /* Generates a warning - but it always works */
        //# define SQLITE_INT_TO_PTR(X)  ((void*)(X))
        //# define SQLITE_PTR_TO_INT(X)  ((int)(X))
        //#endif


        /*
** Exactly one of the following macros must be defined in order to
** specify which memory allocation subsystem to use.
**
**     SQLITE_SYSTEM_MALLOC          // Use normal system malloc()
**     SQLITE_MEMDEBUG               // Debugging version of system malloc()
**
** (Historical note:  There used to be several other options, but we've
** pared it down to just these two.)
**
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
** the default.
*/
        //#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\
        //# error "At most one of the following compile-time configuration options\
        // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG"
        //#endif
        //#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\
        //# define SQLITE_SYSTEM_MALLOC 1
        //#endif

        /*
    ** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
    ** sizes of memory allocations below this value where possible.
    */
#if !(SQLITE_MALLOC_SOFT_LIMIT)
        private const int SQLITE_MALLOC_SOFT_LIMIT = 1024;
#endif

        /*
** We need to define _XOPEN_SOURCE as follows in order to enable
** recursive mutexes on most Unix systems.  But Mac OS X is different.
** The _XOPEN_SOURCE define causes problems for Mac OS X we are told,
** so it is omitted there.  See ticket #2673.
**
** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
** implemented on some systems.  So we avoid defining it at all
** if it is already defined or if it is unneeded because we are
** not doing a threadsafe build.  Ticket #2681.
**
** See also ticket #2741.
*/
#if !_XOPEN_SOURCE && !__DARWIN__ && !__APPLE__ && SQLITE_THREADSAFE
const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500  /* Needed to enable pthread recursive mutexes */
#endif

        /*
** The TCL headers are only needed when compiling the TCL bindings.
*/
#if SQLITE_TCL || TCLSH
//# include <tcl.h>
#endif

        /*
** Many people are failing to set -DNDEBUG=1 when compiling SQLite.
** Setting NDEBUG makes the code smaller and run faster.  So the following
** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1
** option is set.  Thus NDEBUG becomes an opt-in rather than an opt-out
** feature.
*/
#if !NDEBUG && !SQLITE_DEBUG
const int NDEBUG = 1;//# define NDEBUG 1
#endif



        /*
** The TESTONLY macro is used to enclose variable declarations or
** other bits of code that are needed to support the arguments
** within UnitTest.TestCase() and assert() macros.
*/
#if !NDEBUG || SQLITE_COVERAGE_TEST
    //# define TESTONLY(X)  X
    // -- Need workaround for C#, since inline macros don't exist
#else
//# define TESTONLY(X)
#endif

        /*
** Sometimes we need a small amount of code such as a variable initialization
** to setup for a later assert() statement.  We do not want this code to
** appear when assert() is disabled.  The following macro is therefore
** used to contain that setup code.  The "VVA" acronym stands for
** "Verification, Validation, and Accreditation".  In other words, the
** code within VVA_ONLY() will only run during verification processes.
*/
#if !NDEBUG
    //# define VVA_ONLY(X)  X
#else
//# define VVA_ONLY(X)
#endif



        //#include "sqlite3.h"
        //#include "hash.h"
        //#include "parse.h"
        //#include <stdio.h>
        //#include <stdlib.h>
        //#include <string.h>
        //#include <assert.h>
        //#include <stddef.h>





        /*
    ** Determine whether triggers are recursive by default.  This can be
    ** changed at run-time using a pragma.
    */
#if !SQLITE_DEFAULT_RECURSIVE_TRIGGERS
        //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0
        public static bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS;
#else
static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = true;
#endif


        /*
** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
** on the command-line
*/
#if !SQLITE_TEMP_STORE
        private static int SQLITE_TEMP_STORE = 1; //#define SQLITE_TEMP_STORE 1
#endif

        /*
** GCC does not define the offsetof() macro so we'll have to do it
** ourselves.
*/
#if !offsetof
        //#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
#endif

        /*
** Check to see if this machine uses EBCDIC.  (Yes, believe it or
** not, there are still machines out there that use EBCDIC.)
*/
#if FALSE //'A' == '\301'
//# define SQLITE_EBCDIC 1
#else
        private const int SQLITE_ASCII = 1; //#define SQLITE_ASCII 1
#endif

        /*
** Integers of known sizes.  These typedefs might change for architectures
** where the sizes very.  Preprocessor macros are available so that the
** types can be conveniently redefined at compile-type.  Like this:
**
**         cc '-Du32PTR_TYPE=long long int' ...
*/
        //#if !u32_TYPE
        //# ifdef HAVE_u32_T
        //#  define u32_TYPE u32_t
        //# else
        //#  define u32_TYPE unsigned int
        //# endif
        //#endif
        //#if !u3216_TYPE
        //# ifdef HAVE_u3216_T
        //#  define u3216_TYPE u3216_t
        //# else
        //#  define u3216_TYPE unsigned short int
        //# endif
        //#endif
        //#if !INT16_TYPE
        //# ifdef HAVE_INT16_T
        //#  define INT16_TYPE int16_t
        //# else
        //#  define INT16_TYPE short int
        //# endif
        //#endif
        //#if !u328_TYPE
        //# ifdef HAVE_u328_T
        //#  define u328_TYPE u328_t
        //# else
        //#  define u328_TYPE unsigned char
        //# endif
        //#endif
        //#if !INT8_TYPE
        //# ifdef HAVE_INT8_T
        //#  define INT8_TYPE int8_t
        //# else
        //#  define INT8_TYPE signed char
        //# endif
        //#endif
        //#if !LONGDOUBLE_TYPE
        //# define LONGDOUBLE_TYPE long double
        //#endif
        //typedef long long;          /* 8-byte signed integer */
        //typedef sqlite_u3264 ulong;         /* 8-byte unsigned integer */
        //typedef u32_TYPE uint;           /* 4-byte unsigned integer */
        //typedef u3216_TYPE ushort;           /* 2-byte unsigned integer */
        //typedef INT16_TYPE short;            /* 2-byte signed integer */
        //typedef u328_TYPE byte;             /* 1-byte unsigned integer */
        //typedef INT8_TYPE i8;              /* 1-byte signed integer */

      


        /*
    ** Macros to determine whether the machine is big or little endian,
    ** evaluated at runtime.
    */
#if SQLITE_AMALGAMATION
//const int sqlite3one = 1;
#else
        private const bool sqlite3one = true;
#endif
#if i386 || __i386__ || _M_IX86
const int ;//#define SQLITE_BIGENDIAN    0
const int ;//#define SQLITE_LITTLEENDIAN 1
const int ;//#define SQLITE_UTF16NATIVE  Const.SQLITE_UTF16LE
#else
        private static byte SQLITE_BIGENDIAN; //#define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
        private static byte SQLITE_LITTLEENDIAN = 1; //#define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)

        private static readonly byte SQLITE_UTF16NATIVE = (SQLITE_BIGENDIAN != 0 ? Const.SQLITE_UTF16BE : Const.SQLITE_UTF16LE);
                                     //#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?Const.SQLITE_UTF16BE:Const.SQLITE_UTF16LE)
#endif

   

        /*
    ** Assert that the pointer X is aligned to an 8-byte boundary.  This
    ** macro is used only within assert() to verify that the code gets
    ** all alignment restrictions correct.
    **
    ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
    ** underlying malloc() implemention might return us 4-byte aligned
    ** pointers.  In that case, only verify 4-byte alignment.
    */
        //#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
        //# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)
        //#else
        //# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)
        //#endif




        /*
    ** Forward references to structures
    */
        //typedef struct AggInfo AggInfo;
        //typedef struct AuthContext AuthContext;
        //typedef struct AutoincInfo AutoincInfo;
        //typedef struct Bitvec Bitvec;
        //typedef struct CollSeq CollSeq;
        //typedef struct Column Column;
        //typedef struct Db Db;
        //typedef struct Schema Schema;
        //typedef struct Expr Expr;
        //typedef struct ExprList ExprList;
        //typedef struct ExprSpan ExprSpan;
        //typedef struct FKey FKey;
        //typedef struct FuncDef FuncDef;
        //typedef struct IdList IdList;
        //typedef struct Index Index;
        //typedef struct IndexSample IndexSample;
        //typedef struct KeyClass KeyClass;
        //typedef struct KeyInfo KeyInfo;
        //typedef struct Lookaside Lookaside;
        //typedef struct LookasideSlot LookasideSlot;
        //typedef struct Module Module;
        //typedef struct NameContext NameContext;
        //typedef struct Parse Parse;
        //typedef struct RowSet RowSet;
        //typedef struct Savepoint Savepoint;
        //typedef struct Select Select;
        //typedef struct SrcList SrcList;
        //typedef struct StrAccum StrAccum;
        //typedef struct Table Table;
        //typedef struct TableLock TableLock;
        //typedef struct Token Token;
        //typedef struct Trigger Trigger;
        //typedef struct TriggerPrg TriggerPrg;
        //typedef struct TriggerStep TriggerStep;
        //typedef struct UnpackedRecord UnpackedRecord;
        //typedef struct VTable VTable;
        //typedef struct Walker Walker;
        //typedef struct WherePlan WherePlan;
        //typedef struct WhereInfo WhereInfo;
        //typedef struct WhereLevel WhereLevel;

        /*
    ** Defer sourcing vdbe.h and btree.h until after the "byte" and
    ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
    ** pointer types (i.e. FuncDef) defined above.
    */
        //#include "btree.h"
        //#include "vdbe.h"
        //#include "pager.h"
        //#include "pcache_g.h"

        //#include "os.h"
        //#include "mutex.h"








        /*
    ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
    ** used to create the initializers for the FuncDef structures.
    **
    **   FUNCTION(zName, nArg, iArg, bNC, xFunc)
    **     Used to create a scalar function definition of a function zName
    **     implemented by C function xFunc that accepts nArg arguments. The
    **     value passed as iArg is cast to a (void*) and made available
    **     as the user-data (sqlite3_user_data()) for the function. If
    **     argument bNC is true, then the FuncDefFlag.SQLITE_FUNC_NEEDCOLL flag is set.
    **
    **   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
    **     Used to create an aggregate function definition implemented by
    **     the C functions xStep and xFinal. The first four parameters
    **     are interpreted in the same way as the first 4 parameters to
    **     FUNCTION().
    **
    **   LIKEFUNC(zName, nArg, pArg, flags)
    **     Used to create a scalar function definition of a function zName
    **     that accepts nArg arguments and is implemented by a call to C
    **     function likeFunc. Argument pArg is cast to a (void *) and made
    **     available as the function user-data (sqlite3_user_data()). The
    **     FuncDef.flags variable is set to the value passed as the flags
    **     parameter.
    */
        //#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
        //  {nArg, Const.SQLITE_UTF8, bNC*FuncDefFlag.SQLITE_FUNC_NEEDCOLL, \
        //SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0}

        private static FuncDef FUNCTION(string zName, short nArg, int iArg, byte bNC, dxFunc xFunc)
        {
            return new FuncDef(zName, Const.SQLITE_UTF8, nArg, iArg, (byte) (bNC*FuncDefFlag.SQLITE_FUNC_NEEDCOLL), xFunc);
        }

        //#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
        //  {nArg, Const.SQLITE_UTF8, bNC*FuncDefFlag.SQLITE_FUNC_NEEDCOLL, \
        //pArg, 0, xFunc, 0, 0, #zName, 0}

        //#define LIKEFUNC(zName, nArg, arg, flags) \
        //  {nArg, Const.SQLITE_UTF8, flags, (void *)arg, 0, likeFunc, 0, 0, #zName, 0}
        private static FuncDef LIKEFUNC(string zName, short nArg, object arg, byte flags)
        {
            return new FuncDef(zName, Const.SQLITE_UTF8, nArg, arg, likeFunc, flags);
        }

        //#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
        //  {nArg, Const.SQLITE_UTF8, nc*FuncDefFlag.SQLITE_FUNC_NEEDCOLL, \
        //SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0}

        private static FuncDef AGGREGATE(string zName, short nArg, int arg, byte nc, dxStep xStep, dxFinal xFinal)
        {
            return new FuncDef(zName, Const.SQLITE_UTF8, nArg, arg, (byte) (nc*FuncDefFlag.SQLITE_FUNC_NEEDCOLL), xStep, xFinal);
        }






        //#define sqlite3IsNumericAffinity(X)  ((X)>=ColumnAffinityType.SQLITE_AFF_NUMERIC)

        /*
    ** The SQLITE_AFF_MASK values masks off the significant bits of an
    ** affinity value.
    */
        private const int SQLITE_AFF_MASK = 0x67; //#define SQLITE_AFF_MASK     0x67


        /*
    ** Allowed values for Tabe.tabFlags.
    */
        //#define TabFlag.TF_Readonly        0x01    /* Read-only system table */
        //#define TabFlag.TF_Ephemeral       0x02    /* An ephemeral table */
        //#define TabFlag.TF_HasPrimaryKey   0x04    /* Table has a primary key */
        //#define TabFlag.TF_Autoincrement   0x08    /* Integer primary key is autoincrement */
        //#define TabFlag.TF_Virtual         0x10    /* Is a virtual table */
        //#define TabFlag.TF_NeedMetadata    0x20    /* aCol[].zType and aCol[].pColl missing */
      


    

        /*
    ** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
    ** Usually it is 16-bits.  But if SqliteLimit.SQLITE_MAX_VARIABLE_NUMBER is greater
    ** than 32767 we have to make it 32-bit.  16-bit is preferred because
    ** it uses less memory in the Expr object, which is a big memory user
    ** in systems with lots of prepared statements.  And few applications
    ** need more than about 10 or 20 variables.  But some extreme users want
    ** to have prepared statements with over 32767 variables, and for them
    ** the option is available (at compile-time).
    */
        //#if SQLITE_MAX_VARIABLE_NUMBER<=32767
        //typedef short ynVar;
        //#else
        //typedef int ynVar;
        //#endif


     













        /*
    ** A trigger is either a BEFORE or an AFTER trigger.  The following constants
    ** determine which.
    **
    ** If there are multiple triggers, you might of some BEFORE and some AFTER.
    ** In that cases, the constants below can be ORed together.
    */
        private const byte TRIGGER_BEFORE = 1; //#define TRIGGER_BEFORE  1
        private const byte TRIGGER_AFTER = 2; //#define TRIGGER_AFTER   2


        /* Forward declarations */
        //int sqlite3WalkExpr(Walker*, Expr*);
        //int sqlite3WalkExprList(Walker*, ExprList*);
        //int sqlite3WalkSelect(Walker*, Select*);
        //int sqlite3WalkSelectExpr(Walker*, Select*);
        //int sqlite3WalkSelectFrom(Walker*, Select*);



        /*
    ** Assuming zIn points to the first byte of a UTF-8 character,
    ** advance zIn to point to the first byte of the next UTF-8 character.
    */
        //#define SQLITE_SKIP_UTF8(zIn) {                        \
        //  if( (*(zIn++))>=0xc0 ){                              \
        //    while( (*zIn & 0xc0)==0x80 ){ zIn++; }             \
        //  }                                                    \
        //}
        private static void SQLITE_SKIP_UTF8(string zIn, ref int iz)
        {
            iz++;
            if (iz < zIn.Length && zIn[iz - 1] >= 0xC0)
            {
                while (iz < zIn.Length && (zIn[iz] & 0xC0) == 0x80)
                {
                    iz++;
                }
            }
        }

        private static void SQLITE_SKIP_UTF8(
            byte[] zIn, ref int iz)
        {
            iz++;
            if (iz < zIn.Length && zIn[iz - 1] >= 0xC0)
            {
                while (iz < zIn.Length && (zIn[iz] & 0xC0) == 0x80)
                {
                    iz++;
                }
            }
        }



        /*
** Internal function prototypes
*/
        //int Utility.Sqlite3StrICmp(const char *, const char *);
        //int Utility.Sqlite3IsNumber(const char*, int*, byte);
        //int Utility.Sqlite3Strlen30(const char*);
        //#define Utility.Sqlite3StrNICmp sqlite3_strnicmp

        //int Malloc.MallocInit(void);
        //void Malloc.MallocEnd(void);
        //void *Malloc.sqlite3Malloc(int);
        //void *Malloc.MallocZero(int);
        //void *Malloc.DbMallocZero(sqlite3*, int);
        //void *sqlite3DbMallocRaw(sqlite3*, int);
        //char *sqlite3DbStrDup(sqlite3*,const char*);
        //char *sqlite3DbStrNDup(sqlite3*,const char*, int);
        //void *sqlite3Realloc(void*, int);
        //void *Malloc.DbReallocOrFree(sqlite3 *, void *, int);
        //void *Malloc.DbRealloc(sqlite3 *, void *, int);
        //void MemPool.DbFree(sqlite3*, void*);
        //int Malloc.MallocSize(void*);
        //int sqlite3DbMallocSize(sqlite3*, void*);
        //void *Malloc.ScratchMalloc(int);
        //void //sqlite3ScratchFree(void*);
        //void *sqlite3PageMalloc(int);
        //void sqlite3PageFree(void*);
        //void MemPool.MemSetDefault(void);
        //void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
        //int sqlite3MemoryAlarm(void (*)(void*, long, int), void*, long);

        /*
    ** On systems with ample stack space and that support alloca(), make
    ** use of alloca() to obtain space for large automatic objects.  By default,
    ** obtain space from malloc().
    **
    ** The alloca() routine never returns NULL.  This will cause code paths
    ** that deal with sqlite3StackAlloc() failures to be unreachable.
    */
#if SQLITE_USE_ALLOCA
//# define sqlite3StackAllocRaw(D,N)   alloca(N)
//# define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)
//# define sqlite3StackFree(D,P)
#else
#if FALSE
//# define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)
static void sqlite3StackAllocRaw( sqlite3 D, int N ) { sqlite3DbMallocRaw( D, N ); }
//# define sqlite3StackAllocZero(D,N)  Malloc.DbMallocZero(D,N)
static void sqlite3StackAllocZero( sqlite3 D, int N ) { Malloc.DbMallocZero( D, N ); }
//# define sqlite3StackFree(D,P)       MemPool.DbFree(D,P)
static void sqlite3StackFree( sqlite3 D, object P ) {MemPool.DbFree( D, P ); }
#endif
#endif

#if SQLITE_ENABLE_MEMSYS3
const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
#endif
#if SQLITE_ENABLE_MEMSYS5
const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
#endif

#if !SQLITE_MUTEX_OMIT
//  sqlite3_mutex_methods *sqlite3DefaultMutex(void);
//  sqlite3_mutex *MutexHelper.MutexAlloc(int);
//  int MutexHelper.MutexInit(void);
//  int MutexHelper.MutexEnd(void);
#endif

        //int StatusHelper.StatusValue(int);
        //void StatusHelper.StatusAdd(int, int);
        //void StatusHelper.StatusSet(int, int);

        //#ifndef SQLITE_OMIT_FLOATING_POINT
        //  int Utility.Sqlite3IsNaN(double);
        //#else
        //# define Utility.Sqlite3IsNaN(X)  0
        //#endif

        //void Print.VXPrintf(StrAccum*, int, const char*, va_list);
#if!SQLITE_OMIT_TRACE
        //void Print.XPrintf(StrAccum*, const char*, ...);
#endif
        //char *Print.MPrintf(sqlite3*,const char*, ...);
        //char *Print.VMPrintf(sqlite3*,const char*, va_list);
        //char *Print.MAppendf(sqlite3*,char*,const char*,...);
#if SQLITE_TEST || SQLITE_DEBUG
        //  void Print.DebugPrintf(const char*, ...);
#endif
#if SQLITE_TEST
    //  void *sqlite3TestTextToPtr(const char*);
#endif
        //void Malloc.SetString(char **, sqlite3*, const char*, ...);
        //void Utility.Sqlite3ErrorMsg(Parse*, const char*, ...);
        //int Utility.Sqlite3Dequote(char*);
        //int KeywordHash.KeywordCode(const unsigned char*, int);
        //int Tokenize.RunParser(Parse*, const char*, char **);
        //void Build.FinishCoding(Parse*);
        //int ExprHelper.GetTempReg(Parse*);
        //void ExprHelper.ReleaseTempReg(Parse*,int);
        //int ExprHelper.GetTempRange(Parse*,int);
        //void ExprHelper.ReleaseTempRange(Parse*,int,int);
        //Expr *ExprHelper.ExprAlloc(sqlite3*,int,const Token*,int);
        //Expr *ExprHeler.NewExpr(sqlite3*,int,const char*);
        //void ExprHelper.ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);
        //Expr *ExprHelper.PExpr(Parse*, int, Expr*, Expr*, const Token*);
        //Expr *ExprHelper.ExprAnd(sqlite3*,Expr*, Expr*);
        //Expr *ExprHelper.ExprFunction(Parse*,ExprList*, Token*);
        //void ExprHelper.ExprAssignVarNumber(Parse*, Expr*);
        //void ExprHeler.ExprDelete(sqlite3*, Expr*);
        //ExprList *ExprHelper.ExprListAppend(Parse*,ExprList*,Expr*);
        //void ExprHelper.ExprListSetName(Parse*,ExprList*,Token*,int);
        //void ExprHelper.ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
        //void ExprHelper.ExprListDelete(sqlite3*, ExprList*);
        //int sqlite3Init(sqlite3*, char**);
        //int sqlite3InitCallback(void*, int, char**, char**);
        //void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
        //void Build.ResetInternalSchema(sqlite3*, int);
        //void Build.BeginParse(Parse*,int);
        //void Build.CommitInternalChanges(sqlite3*);
        //Table *sqlite3ResultSetOfSelect(Parse*,Select*);
        //void Build.OpenMasterTable(Parse *, int);
        //void Build.StartTable(Parse*,Token*,Token*,int,int,int,int);
        //void Build.AddColumn(Parse*,Token*);
        //void Build.AddNotNull(Parse*, int);
        //void Build.AddPrimaryKey(Parse*, ExprList*, int, int, int);
        //void Build.AddCheckConstraint(Parse*, Expr*);
        //void Build.AddColumnType(Parse*,Token*);
        //void Build.AddDefaultValue(Parse*,ExprSpan*);
        //void Build.AddCollateType(Parse*, Token*);
        //void Build.EndTable(Parse*,Token*,Token*,Select*);

        //Bitvec *sqlite3BitvecCreate(uint);
        //int sqlite3BitvecTest(Bitvec*, uint);
        //int sqlite3BitvecSet(Bitvec*, uint);
        //void sqlite3BitvecClear(Bitvec*, uint, void*);
        //void sqlite3BitvecDestroy(Bitvec*);
        //uint sqlite3BitvecSize(Bitvec*);
        //int sqlite3BitvecBuiltinTest(int,int*);

        //RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
        //void sqlite3RowSetClear(RowSet*);
        //void sqlite3RowSetInsert(RowSet*, long);
        //int sqlite3RowSetTest(RowSet*, byte iBatch, long);
        //int sqlite3RowSetNext(RowSet*, long*);

        //void Build.CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);

        //#if !(SQLITE_OMIT_VIEW) || !SQLITE_OMIT_VIRTUALTABLE)
        //  int Build.ViewGetColumnNames(Parse*,Table*);
        //#else
        //# define Build.ViewGetColumnNames(A,B) 0
        //#endif

        //void Build.DropTable(Parse*, SrcList*, int, int);
        //void Build.DeleteTable(Table*);
        //#if ! SQLITE_OMIT_AUTOINCREMENT
        //  void sqlite3AutoincrementBegin(Parse *pParse);
        //  void sqlite3AutoincrementEnd(Parse *pParse);
        //#else
        //# define sqlite3AutoincrementBegin(X)
        //# define sqlite3AutoincrementEnd(X)
        //#endif
        //void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);
        //void *sqlite3ArrayAllocate(sqlite3*,void*,int,int,int*,int*,int*);
        //IdList *Build.IdListAppend(sqlite3*, IdList*, Token*);
        //int Build.IdListIndex(IdList*,const char*);
        //SrcList *Build.SrcListEnlarge(sqlite3*, SrcList*, int, int);
        //SrcList *Build.SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
        //SrcList *Build.SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
        //                                      Token*, Select*, Expr*, IdList*);
        //void Build.SrcListIndexedBy(Parse *, SrcList *, Token *);
        //int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
        //void Build.SrcListShiftJoinType(SrcList*);
        //void Build.SrcListAssignCursors(Parse*, SrcList*);
        //void Build.IdListDelete(sqlite3*, IdList*);
        //void Build.SrcListDelete(sqlite3*, SrcList*);
        //Index *Build.CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
        //                        Token*, int, int);
        //void Build.DropIndex(Parse*, SrcList*, int);
        //int sqlite3Select(Parse*, Select*, SelectDest*);
        //Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
        //                         Expr*,ExprList*,int,Expr*,Expr*);
        //void sqlite3SelectDelete(sqlite3*, Select*);
        //Table *sqlite3SrcListLookup(Parse*, SrcList*);
        //int sqlite3IsReadOnly(Parse*, Table*, int);
        //void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY)
//Expr *sqlite3LimitWhere(Parse *, SrcList *, Expr *, ExprList *, Expr *, Expr *, char *);
#endif
        //void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
        //void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
        //WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, ushort);
        //void sqlite3WhereEnd(WhereInfo*);
        //int ExprHelper.ExprCodeGetColumn(Parse*, Table*, int, int, int);
        //void ExprHelper.ExprCodeMove(Parse*, int, int, int);
        //void ExprHelper.ExprCodeCopy(Parse*, int, int, int);
        //void ExprHelper.ExprCacheStore(Parse*, int, int, int);
        //void ExprHelper.ExprCachePush(Parse*);
        //void ExprHelper.ExprCachePop(Parse*, int);
        //void ExprHelper.ExprCacheRemove(Parse*, int, int);
        //void ExprHelper.ExprCacheClear(Parse*);
        //void ExprHelper.ExprCacheAffinityChange(Parse*, int, int);
        //void ExprHelper.ExprHardCopy(Parse*,int,int);
        //int ExprHelper.ExprCode(Parse*, Expr*, int);
        //int ExprHelper.ExprCodeTemp(Parse*, Expr*, int*);
        //int ExprHelper.ExprCodeTarget(Parse*, Expr*, int);
        //int ExprHelper.ExprCodeAndCache(Parse*, Expr*, int);
        //void ExprHelper.ExprCodeConstants(Parse*, Expr*);
        //int ExprHelper.ExprCodeExprList(Parse*, ExprList*, int, int);
        //void ExprHelper.ExprIfTrue(Parse*, Expr*, int, int);
        //void ExprHelper.ExprIfFalse(Parse*, Expr*, int, int);
        //Table *Build.FindTable(sqlite3*,const char*, const char*);
        //Table *Build.LocateTable(Parse*,int isView,const char*, const char*);
        //Index *Build.FindIndex(sqlite3*,const char*, const char*);
        //void Build.UnlinkAndDeleteTable(sqlite3*,int,const char*);
        //void Build.UnlinkAndDeleteIndex(sqlite3*,int,const char*);
        //void sqlite3Vacuum(Parse*);
        //int sqlite3RunVacuum(char**, sqlite3*);
        //char *Build.NameFromToken(sqlite3*, Token*);
        //int ExprHelper.ExprCompare(Expr*, Expr*);
        //void ExprHelper.ExprAnalyzeAggregates(NameContext*, Expr*);
        //void ExprHelper.ExprAnalyzeAggList(NameContext*,ExprList*);
        //Vdbe *SelectHelper.GetVdbe(Parse*);
        //void Random.PrngSaveState(void);
        //void Random.PrngRestoreState(void);
        //void Random.PrngResetState(void);
        //void sqlite3RollbackAll(sqlite3*);
        //void Build.CodeVerifySchema(Parse*, int);
        //void Build.BeginTransaction(Parse*, int);
        //void Build.CommitTransaction(Parse*);
        //void Build.RollbackTransaction(Parse*);
        //void Build.Savepoint(Parse*, int, Token*);
        //void sqlite3CloseSavepoints(sqlite3 *);
        //int ExprHelper.ExprIsConstant(Expr*);
        //int ExprHelper.ExprIsConstantNotJoin(Expr*);
        //int ExprHelper.ExprIsConstantOrFunction(Expr*);
        //int ExprHelper.ExprIsInteger(Expr*, int*);
        //int ExprHelper.ExprCanBeNull(const Expr*);
        //void ExprHelper.ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
        //int ExprHelper.ExprNeedsNoAffinityChange(const Expr*, char);
        //int ExprHelper.IsRowid(const char*);
        //void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
        //void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
        //int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
        //void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
        //                                     int*,int,int,int,int,int*);
        //void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
        //int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
        //void Build.BeginWriteOperation(Parse*, int, int);
        //void Build.MultiWrite(Parse*);
        //void Build.MayAbort(Parse *);
        //void Build.HaltConstraint(Parse*, int, char*, int);
        //Expr *ExprHelper.ExprDup(sqlite3*,Expr*,int);
        //ExprList *ExprHelper.ExprListDup(sqlite3*,ExprList*,int);
        //SrcList *ExprHelper.SrcListDup(sqlite3*,SrcList*,int);
        //IdList *ExprHelper.IdListDup(sqlite3*,IdList*);
        //Select *ExprHelper.SelectDup(sqlite3*,Select*,int);
        //void Callback.FuncDefInsert(FuncDefHash*, FuncDef*);
        //FuncDef *Callback.FindFunction(sqlite3*,const char*,int,int,byte,int);
        //void sqlite3RegisterBuiltinFunctions(sqlite3*);
        //void sqlite3RegisterDateTimeFunctions(void);
        //void sqlite3RegisterGlobalFunctions(void);
        //int Utility.Sqlite3SafetyCheckOk(sqlite3*);
        //int Utility.Sqlite3SafetyCheckSickOrOk(sqlite3*);
        //void Build.ChangeCookie(Parse*, int);
#if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER)
        //void sqlite3MaterializeView(Parse*, Table*, Expr*, int);
#endif

#if !SQLITE_OMIT_TRIGGER
        //void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,
        //                         Expr*,int, int);
        //void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);
        //void sqlite3DropTrigger(Parse*, SrcList*, int);
        //Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
        //Trigger *sqlite3TriggerList(Parse *, Table *);
        //  void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
        //                        int, int, int);
        //void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
        //void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
        //TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
        //TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
        //                                      ExprList*,Select*,byte);
        //TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, byte);
        //TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
        //void TriggerHelper.DeleteTrigger(sqlite3*, Trigger*);
        //void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
        //  uint  sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
        //# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
        private static Parse sqlite3ParseToplevel(Parse p)
        {
            return p.pToplevel != null ? p.pToplevel : p;
        }
#else
static void sqlite3BeginTrigger( Parse A, Token B, Token C, int D, int E, IdList F, SrcList G, Expr H, int I, int J ) { }
static void sqlite3FinishTrigger( Parse P, TriggerStep TS, Token T ) { }
static TriggerStep sqlite3TriggerSelectStep( sqlite3 A, Select B ) { return null; }
static TriggerStep sqlite3TriggerInsertStep( sqlite3 A, Token B, IdList C, ExprList D, Select E, byte F ) { return null; }
static TriggerStep sqlite3TriggerUpdateStep( sqlite3 A, Token B, ExprList C, Expr D, byte E ) { return null; }
static TriggerStep sqlite3TriggerDeleteStep( sqlite3 A, Token B, Expr C ) { return null; }
static uint sqlite3TriggerColmask( Parse A, Trigger B, ExprList C, int D, int E, Table F, int G ) { return 0; }

//# define sqlite3TriggersExist(B,C,D,E,F) 0
static Trigger sqlite3TriggersExist( Parse B, Table C, int D, ExprList E, ref int F ) { return null; }

//# define TriggerHelper.DeleteTrigger(A,B)
static void TriggerHelper.DeleteTrigger( sqlite3 A, ref Trigger B ) { }
static void sqlite3DeleteTriggerStep( sqlite3 A, ref TriggerStep B ) { }

//# define sqlite3DropTriggerPtr(A,B)
static void sqlite3DropTriggerPtr( Parse A, Trigger B ) { }
static void sqlite3DropTrigger( Parse A, SrcList B, int C ) { }

//# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
static void sqlite3UnlinkAndDeleteTrigger( sqlite3 A, int B, string C ) { }

//# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)
static void sqlite3CodeRowTrigger( Parse A, Trigger B, int C, ExprList D, int E, Table F, int G, int H, int I ) { }

//# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
static Trigger sqlite3TriggerList( Parse pParse, Table pTab ) { return null; } //# define sqlite3TriggerList(X, Y) 0

//# define sqlite3ParseToplevel(p) p
static Parse sqlite3ParseToplevel( Parse p ) { return p; }

//# define sqlite3TriggerOldmask(A,B,C,D,E,F) 0
static uint sqlite3TriggerOldmask( Parse A, Trigger B, int C, ExprList D, Table E, int F ) { return 0; }
#endif

        //int sqlite3JoinType(Parse*, Token*, Token*, Token*);
        //void Build.CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
        //void Build.DeferForeignKey(Parse*, int);
#if !SQLITE_OMIT_AUTHORIZATION
void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);
void sqlite3AuthContextPop(AuthContext*);
int sqlite3AuthReadCol(Parse*, const char *, const char *, int);
#else
        //# define sqlite3AuthRead(a,b,c,d)
        private static void sqlite3AuthRead(Parse a, Expr b, Schema c, SrcList d)
        {
        }

        //# define sqlite3AuthCheck(a,b,c,d,e)    StatusCode.SQLITE_OK
        private static int sqlite3AuthCheck(Parse a, int b, string c, byte[] d, byte[] e)
        {
            return StatusCode.SQLITE_OK;
        }

        //# define sqlite3AuthContextPush(a,b,c)
        private static void sqlite3AuthContextPush(Parse a, AuthContext b, string c)
        {
        }

        //# define sqlite3AuthContextPop(a)  ((void)(a))
        private static Parse sqlite3AuthContextPop(Parse a)
        {
            return a;
        }
#endif
        //void AttachHelper.Attach(Parse*, Expr*, Expr*, Expr*);
        //void AttachHelper.Detach(Parse*, Expr*);
        //int sqlite3BtreeFactory(sqlite3 db, const char *zFilename,
        //                       int omitJournal, int nCache, int flags, Btree **ppBtree);
        //int AttachHelper.FixInit(DbFixer*, Parse*, int, const char*, const Token*);
        //int AttachHelper.FixSrcList(DbFixer*, SrcList*);
        //int AttachHelper.FixSelect(DbFixer*, Select*);
        //int AttachHelper.FixExpr(DbFixer*, Expr*);
        //int AttachHelper.FixExprList(DbFixer*, ExprList*);
        //int AttachHelper.FixTriggerStep(DbFixer*, TriggerStep*);
        //int Utility.Sqlite3AtoF(const char *z, double*);
        //int Utility.Sqlite3GetInt32(const char *, int*);
        //int sqlite3FitsIn64Bits(const char *, int);
        //int sqlite3Utf16ByteLen(const void pData, int nChar);
        //int UtfHelper.Utf8CharLen(const char pData, int nByte);
        //int UtfHelper.Utf8Read(const byte*, const byte**);

        /*
    ** Routines to read and write variable-length integers.  These used to
    ** be defined locally, but now we use the varint routines in the util.c
    ** file.  Code should use the MACRO forms below, as the Varint32 versions
    ** are coded to assume the single byte case is already handled (which
    ** the MACRO form does).
    */
        //int Sqlite3PutVarint(unsigned char*, ulong);
        //int Utility.PutVarint32(unsigned char*, uint);
        //byte Sqlite3GetVarint(const unsigned char *, ulong *);
        //byte Utility.Sqlite3GetVarint32(const unsigned char *, uint *);
        //int Utility.Sqlite3VarintLen(ulong v);

        /*
    ** The header of a record consists of a sequence variable-length integers.
    ** These integers are almost always small and are encoded as a single byte.
    ** The following macros take advantage this fact to provide a fast encode
    ** and decode of the integers in a record header.  It is faster for the common
    ** case where the integer is a single byte.  It is a little slower when the
    ** integer is two or more bytes.  But overall it is faster.
    **
    ** The following expressions are equivalent:
    **
    **     x = Utility.Sqlite3GetVarint32( A, B );
    **     x = Utility.PutVarint32( A, B );
    **
    **     x = Utility.GetVarint32( A, B );
    **     x = Utility.PutVarint32( A, B );
    **
    */
        //#define Utility.GetVarint32(A,B)  (byte)((*(A)<(byte)0x80) ? ((B) = (uint)*(A)),1 : Utility.Sqlite3GetVarint32((A), (uint *)&(B)))
        //#define Utility.PutVarint32(A,B)  (byte)(((uint)(B)<(uint)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B)))
        //#define getVarint    Sqlite3GetVarint
        //#define Utility.PutVarint    Sqlite3PutVarint


        //const char *sqlite3IndexAffinityStr(Vdbe *, Index *);
        //void sqlite3TableAffinityStr(Vdbe *, Table *);
        //char ExprHelper.CompareAffinity(Expr pExpr, char aff2);
        //int ExprHelper.IndexAffinityOk(Expr pExpr, char idx_affinity);
        //char ExprHelper.ExprAffinity(Expr pExpr);
        //int Utility.Sqlite3Atoi64(const char*, long*);
        //void Utility.Sqlite3Error(sqlite3*, int, const char*,...);
        //void *Utility.Sqlite3HexToBlob(sqlite3*, const char *z, int n);
        //int Build.TwoPartName(Parse *, Token *, Token *, Token **);
        //const char *Utility.ErrorString(int);
        //int Prepare.ReadSchema(Parse pParse);
        //CollSeq *Callback.FindCollSeq(sqlite3*,byte enc, const char*,int);
        //CollSeq *Build.LocateCollSeq(Parse *pParse, const char*zName);
        //CollSeq *ExprHelper.ExprCollSeq(Parse pParse, Expr pExpr);
        //Expr *ExprHelper.ExprSetColl(Parse pParse, Expr *, Token *);
        //int Callback.CheckCollSeq(Parse *, CollSeq *);
        //int Build.CheckObjectName(Parse *, const char *);
        //void VdbeAux.VdbeSetChanges(sqlite3 *, int);

        //const void *sqlite3ValueText(sqlite3_value*, byte);
        //int sqlite3ValueBytes(sqlite3_value*, byte);
        //void sqlite3ValueSetStr(sqlite3_value*, int, const void *,byte,
        //                      //  void(*)(void*));
        //void sqlite3ValueFree(sqlite3_value*);
        //sqlite3_value *sqlite3ValueNew(sqlite3 *);
        //char *sqlite3Utf16to8(sqlite3 *, const void*, int, byte);
        //#ifdef SQLITE_ENABLE_STAT2
        //char *sqlite3Utf8to16(sqlite3 *, byte, char *, int, int *);
        //#endif
        //int sqlite3ValueFromExpr(sqlite3 *, Expr *, byte, byte, sqlite3_value **);
        //void sqlite3ValueApplyAffinity(sqlite3_value *, byte, byte);
        //#if !SQLITE_AMALGAMATION
        //extern const unsigned char Global.Sqlite3OpcodeProperty[];
        //extern const unsigned char Global.Sqlite3UpperToLower[];
        //extern const unsigned char Global.Sqlite3CtypeMap[];
        //extern struct Sqlite3Config sqlite3Config;
        //extern FuncDefHash Global.Sqlite3GlobalFunctions;
        //extern int Global.Sqlite3PendingByte;
        //#endif
        //void Build.RootPageMoved(Db*, int, int);
        //void Build.Reindex(Parse*, Token*, Token*);
        //void Alter.AlterFunctions(sqlite3*);
        //void Build.AlterRenameTable(Parse*, SrcList*, Token*);
        //int Tokenize.GetToken(const unsigned char *, int *);
        //void Build.NestedParse(Parse*, const char*, ...);
        //void sqlite3ExpirePreparedStatements(sqlite3*);
        //int ExprHelper.CodeSubselect(Parse *, Expr *, int, int);
        //void sqlite3SelectPrep(Parse*, Select*, NameContext*);
        //int sqlite3ResolveExprNames(NameContext*, Expr*);
        //void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
        //int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
        //void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
        //void sqlite3AlterFinishAddColumn(Parse *, Token *);
        //void Build.AlterBeginAddColumn(Parse *, SrcList *);
        //CollSeq *Callback.GetCollSeq(sqlite3*, byte, CollSeq *, const char*);
        //char Build.AffinityType(const char*);
        //void sqlite3Analyze(Parse*, Token*, Token*);
        //int sqlite3InvokeBusyHandler(BusyHandler*);
        //int Build.FindDb(sqlite3*, Token*);
        //int Build.FindDbName(sqlite3 *, const char *);
        //int sqlite3AnalysisLoad(sqlite3*,int iDB);
        //void sqlite3DeleteIndexSamples(Index*);
        //void Build.DefaultRowEst(Index*);
        //void sqlite3RegisterLikeFunctions(sqlite3*, int);
        //int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
        //void Build.MinimumFileFormat(Parse*, int, int);
        //void Callback.SchemaFree(void *);
        //Schema *Callback.SchemaGet(sqlite3 *, Btree *);
        //int sqlite3SchemaToIndex(sqlite3 db, Schema *);
        //KeyInfo *Build.IndexKeyinfo(Parse *, Index *);
        //int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
        //  void (*)(sqlite3_context*,int,sqlite3_value **),
        //  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*));
        //int Malloc.ApiExit(sqlite3 db, int);
        //int Build.OpenTempDatabase(Parse *);

        //void Print.StrAccumAppend(StrAccum*,const char*,int);
        //char *Print.StrAccumFinish(StrAccum*);
        //void sqlite3StrAccumReset(StrAccum*);
        //void sqlite3SelectDestInit(SelectDest*,int,int);
        //Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);

        //void sqlite3BackupRestart(sqlite3_backup *);
        //void sqlite3BackupUpdate(sqlite3_backup *, uint, const byte *);

        /*
    ** The interface to the LEMON-generated parser
    */
        //void *sqlite3ParserAlloc(void*(*)(size_t));
        //void sqlite3ParserFree(void*, void(*)(void*));
        //void sqlite3Parser(void*, int, Token, Parse*);
#if YYTRACKMAXSTACKDEPTH
int sqlite3ParserStackPeak(void*);
#endif

        //void sqlite3AutoLoadExtensions(sqlite3*);
#if !SQLITE_OMIT_LOAD_EXTENSION
        //void sqlite3CloseExtensions(sqlite3*);
#else
//# define sqlite3CloseExtensions(X)
#endif

#if !SQLITE_OMIT_SHARED_CACHE
//void sqlite3TableLock(Parse *, int, int, byte, const char *);
#else
        //#define sqlite3TableLock(v,w,x,y,z)
        private static void sqlite3TableLock(Parse p, int p1, int p2, byte p3, byte[] p4)
        {
        }

        private static void sqlite3TableLock(Parse p, int p1, int p2, byte p3, string p4)
        {
        }
#endif

#if SQLITE_TEST
    ///int sqlite3Utf8To8(unsigned char*);
#endif

#if SQLITE_OMIT_VIRTUALTABLE
        //#  define sqlite3VtabClear(Y)
        private static void sqlite3VtabClear(Table Y)
        {
        }

        //#  define sqlite3VtabSync(X,Y) StatusCode.SQLITE_OK
        private static int sqlite3VtabSync(sqlite3 X, string Y)
        {
            return StatusCode.SQLITE_OK;
        }

        //#  define sqlite3VtabRollback(X)
        private static void sqlite3VtabRollback(sqlite3 X)
        {
        }

        //#  define sqlite3VtabCommit(X)
        private static void sqlite3VtabCommit(sqlite3 X)
        {
        }

        //#  define sqlite3VtabInSync(db) 0
        //#  define sqlite3VtabLock(X) 
        private static void sqlite3VtabLock(VTable X)
        {
        }

        //#  define sqlite3VtabUnlock(X)
        private static void sqlite3VtabUnlock(VTable X)
        {
        }

        //#  define sqlite3VtabUnlockList(X)
        private static void sqlite3VtabUnlockList(sqlite3 X)
        {
        }

        private static void sqlite3VtabArgExtend(Parse P, Token T)
        {
        }

//#  define sqlite3VtabArgExtend(P, T)
        private static void sqlite3VtabArgInit(Parse P)
        {
        }

//#  define sqlite3VtabArgInit(P)
        private static void sqlite3VtabBeginParse(Parse P, Token T, Token T1, Token T2)
        {
        }

//#  define sqlite3VtabBeginParse(P, T, T1, T2);
        private static void sqlite3VtabFinishParse<T>(Parse P, T t)
        {
        }

//#  define sqlite3VtabFinishParse(P, T)
        private static bool sqlite3VtabInSync(sqlite3 db)
        {
            return false;
        }

        private static VTable sqlite3GetVTable(sqlite3 db, Table T)
        {
            return null;
        }
#else
//void sqlite3VtabClear(Table*);
//int sqlite3VtabSync(sqlite3 db, int rc);
//int sqlite3VtabRollback(sqlite3 db);
//int sqlite3VtabCommit(sqlite3 db);
//void sqlite3VtabLock(VTable *);
//void sqlite3VtabUnlock(VTable *);
//void sqlite3VtabUnlockList(sqlite3*);
//#  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
static bool sqlite3VtabInSync( sqlite3 db ) { return ( db.nVTrans > 0 && db.aVTrans == 0 ); }
#endif
        //void sqlite3VtabMakeWritable(Parse*,Table*);
        //void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*);
        //void sqlite3VtabFinishParse(Parse*, Token*);
        //void sqlite3VtabArgInit(Parse*);
        //void sqlite3VtabArgExtend(Parse*, Token*);
        //int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
        //int sqlite3VtabCallConnect(Parse*, Table*);
        //int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
        //int sqlite3VtabBegin(sqlite3 *, VTable *);
        //FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
        //void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
        //int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
        //int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
        //int sqlite3Reprepare(Vdbe*);
        //void ExprHelper.ExprListCheckLength(Parse*, ExprList*, const char*);
        //CollSeq *ExprHelper.BinaryCompareCollSeq(Parse *, Expr *, Expr *);
        //int sqlite3TempInMemory(const sqlite3*);
        //VTable *sqlite3GetVTable(sqlite3*, Table*);

        /* Declarations for functions in fkey.c. All of these are replaced by
    ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
    ** key functionality is available. If OMIT_TRIGGER is defined but
    ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
    ** this case foreign keys are parsed, but no other functionality is 
    ** provided (enforcement of FK constraints requires the triggers sub-system).
    */
#if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER)
        //void sqlite3FkCheck(Parse*, Table*, int, int);
        //void sqlite3FkDropTable(Parse*, SrcList *, Table*);
        //void sqlite3FkActions(Parse*, Table*, ExprList*, int);
        //int sqlite3FkRequired(Parse*, Table*, int*, int);
        //uint sqlite3FkOldmask(Parse*, Table*);
        //FKey *sqlite3FkReferences(Table *);
#else
//#define sqlite3FkActions(a,b,c,d)
static void sqlite3FkActions( Parse a, Table b, ExprList c, int d ) { }

//#define sqlite3FkCheck(a,b,c,d)
static void sqlite3FkCheck( Parse a, Table b, int c, int d ) { }

//#define sqlite3FkDropTable(a,b,c)
static void sqlite3FkDropTable( Parse a, SrcList b, Table c ) { }

//#define sqlite3FkOldmask(a,b)      0
static uint sqlite3FkOldmask( Parse a, Table b ) { return 0; }

//#define sqlite3FkRequired(a,b,c,d) 0
static int sqlite3FkRequired( Parse a, Table b, int[] c, int d ) { return 0; }
#endif
#if !SQLITE_OMIT_FOREIGN_KEY
        //void sqlite3FkDelete(Table*);
#else
//#define sqlite3FkDelete(a)
static void sqlite3FkDelete(Table a) {}                 
#endif

        /*
** Available fault injectors.  Should be numbered beginning with 0.
*/
        private const int SQLITE_FAULTINJECTOR_MALLOC = 0; //#define SQLITE_FAULTINJECTOR_MALLOC     0
        private const int SQLITE_FAULTINJECTOR_COUNT = 1; //#define SQLITE_FAULTINJECTOR_COUNT      1

        /*
    ** The interface to the code in fault.c used for identifying "benign"
    ** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST
    ** is not defined.
    */
#if !SQLITE_OMIT_BUILTIN_TEST
        //void sqlite3BeginBenignMalloc(void);
        //void sqlite3EndBenignMalloc(void);
#else
//#define sqlite3BeginBenignMalloc()
//#define sqlite3EndBenignMalloc()
#endif

   

#if SQLITE_ENABLE_ATOMIC_WRITE
//  int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
//  int sqlite3JournalSize(sqlite3_vfs *);
//  int sqlite3JournalCreate(sqlite3_file *);
#else
        //#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)
        private static int sqlite3JournalSize(sqlite3_vfs pVfs)
        {
            return pVfs.szOsFile;
        }
#endif

        //void sqlite3MemJournalOpen(sqlite3_file *);
        //int sqlite3MemJournalSize(void);
        //int sqlite3IsMemJournal(sqlite3_file *);

#if SQLITE_MAX_EXPR_DEPTH
//>0
        //  void ExprHelper.ExprSetHeight(Parse pParse, Expr p);
        //  int ExprHelper.SelectExprHeight(Select *);
        //int ExprHelper.ExprCheckHeight(Parse*, int);
#else
//#define ExprHelper.ExprSetHeight(x,y)
//#define ExprHelper.SelectExprHeight(x) 0
//#define ExprHelper.ExprCheckHeight(x,y)
#endif

        //uint Utility.Sqlite3Get4byte(const byte*);
        //void sqlite3sqlite3Put4byte(byte*, uint);

#if SQLITE_ENABLE_UNLOCK_NOTIFY
void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);
void sqlite3ConnectionUnlocked(sqlite3 *db);
void sqlite3ConnectionClosed(sqlite3 *db);
#else
        private static void sqlite3ConnectionBlocked(sqlite3 x, sqlite3 y)
        {
        }

        //#define sqlite3ConnectionBlocked(x,y)
        private static void sqlite3ConnectionUnlocked(sqlite3 x)
        {
        }

        //#define sqlite3ConnectionUnlocked(x)
        private static void sqlite3ConnectionClosed(sqlite3 x)
        {
        }

        //#define sqlite3ConnectionClosed(x)
#endif

#if SQLITE_DEBUG
        //  void sqlite3ParserTrace(FILE*, char *);
#endif

        /*
** If the SQLITE_ENABLE IOTRACE exists then the global variable
** sqlite3IoTrace is a pointer to a Custom.Printf-like routine used to
** print I/O tracing messages.
*/
#if SQLITE_ENABLE_IOTRACE
static bool SQLite3IoTrace = false;
//#define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
static void IOTRACE( string X, params object[] ap ) { if ( SQLite3IoTrace ) { Custom.Printf( X, ap ); } }

//  void sqlite3VdbeIOTraceSql(Vdbe);
//SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
#else
        //#define IOTRACE(A)
        private static void IOTRACE(string F, params object[] ap)
        {
        }

        //#define sqlite3VdbeIOTraceSql(X)
        private static void sqlite3VdbeIOTraceSql(Vdbe X)
        {
        }
#endif

        //#endif
    }
}